package com.css.fxfzdzzh.base.dict;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.css.fxfzdzzh.base.dict.service.DictDirectoryService;
import com.css.fxfzdzzh.base.dict.viewobjects.DictDirExcelVO;
import com.css.fxfzdzzh.base.dict.viewobjects.DictDirectoryVO;
import com.css.fxfzdzzh.util.PlatformObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author chenjun
 * @Date 2020/4/26
 * @Description
 */

@Component
public class DictDirExcelVerifyHandler implements IExcelVerifyHandler<DictDirExcelVO> {
    @Autowired
    DictDirectoryService dictDirectoryService;

    @Override
    public ExcelVerifyHandlerResult verifyHandler(DictDirExcelVO dictExcelVo) {
        ExcelVerifyHandlerResult result = new ExcelVerifyHandlerResult(true);
        StringBuilder message = new StringBuilder("");
        DictDirectoryVO dictDirectoryVO = dictDirectoryService.getDictDirectory(dictExcelVo.getDictDirId());
        if(!PlatformObjectUtils.isEmpty(dictDirectoryVO)){
            result.setSuccess(false);
            message.append("字典目录"+dictExcelVo.getDictDirName()+"已存在，");
        }
        result.setMsg(message.toString());
        return result;
    }
}
